package com.parenting.controller;


import com.parenting.model.IMPage;
import com.parenting.oauth2.config.AuthUtil;
import com.parenting.request.wechat.ActivityListConditionRequest;
import com.parenting.response.wechat.*;
import com.parenting.service.*;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活动 前端控制器
 * </p>
 *
 * @author 烟台业达-王世玺
 * @since 2021-08-27
 */
@Api(tags = "活动管理", description = "活动管理，新增、列表")
@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;
    @Autowired
    private ActivityFissionService  activityFissionService;
    /***
     * 裂变零元购 新增
     */
    @ApiOperation("查询裂变零元购详情")
    @ApiImplicitParam(name = "activityId", value = "活动ID", required = true)
    @GetMapping("fission/{activityId}")
    public Result< List<WeChatFissionResponse> > getFissionActivity(@PathVariable("activityId") String activityId){
        List<WeChatFissionResponse> wechatFissionByActivityId = activityFissionService.getWechatFissionByActivityId(activityId);
        return  Result.buildSuccess(wechatFissionByActivityId);
    }

    @Autowired
    private ActivityFreeService activityFreeService;
    /***
     * 免费体验 新增
     */
    @ApiOperation("查询免费体验详情")
    @ApiImplicitParam(name = "activityId", value = "活动ID", required = true)
    @GetMapping("free/{activityId}")
    public Result<List<WeChatFreeResponse>> getFreeActivity(@PathVariable("activityId")String activityId){
        List<WeChatFreeResponse> freeActivity =  activityFreeService.getWeChatFreeActivity(activityId);
        return  Result.buildSuccess(freeActivity);
    }

    @Autowired
    private ActivityVoucherService activityVoucherService;
    /***
     * 代金券活动新增
     */
    @ApiOperation("查询代金券活动详情")
    @ApiImplicitParam(name = "activityId", value = "活动ID", required = true)
    @GetMapping("voucher/{activityId}")
    public Result<List<WechatVoucherResponse>> getVoucherActivity(@PathVariable("activityId")String activityId){
        List<WechatVoucherResponse> wechatVoucher = activityVoucherService.getWechatVoucher(activityId);
        return  Result.buildSuccess(wechatVoucher);
    }

    @Autowired
    private ActivityCollageService activityCollageService;
    /****
     * 添加普通拼
     */
    @ApiOperation("查询普通拼详情")
    @ApiImplicitParam(name = "activityId", value = "活动ID", required = true)
    @GetMapping("collage/{activityId}")
    public Result<List<WeChatCollageResponse>> getCollageActivity(@PathVariable("activityId")String activityId){

        return  Result.buildSuccess(activityCollageService.getWeChatCollageActivity(activityId));
    }
    /***
     * 活动分页列表
     * @param activityBaseRequest
     * @return
     */
    @ApiOperation("活动分页列表")
    @PostMapping("page")
    public Result<IMPage<WechatActivityListResponse>> getWechatActivityPageListByType(@RequestBody ActivityListConditionRequest activityBaseRequest){

        return  Result.buildSuccess(activityService.getWechatActivityPageListByType(activityBaseRequest,AuthUtil.getUserInfo().getShopId()));
    }


    @ApiOperation("活动提醒")
    @PostMapping("notice")
    public Result<List<WechatActivityNoticeResponse>>  activityNotice(){
        List<WechatActivityNoticeResponse> wechatActivityNoticeResponses = activityService.activityNotice(AuthUtil.getUserInfo().getShopId());
        return Result.buildSuccess(wechatActivityNoticeResponses);
    }


}

